/*
*  Copyright 2019-2023 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package com.yangxu.hospital.system.modules.system.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import java.sql.Timestamp;
import java.math.BigDecimal;
import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
* @description /
* @author 杨旭
* @date 2024-12-20
**/
@Data
@TableName("sys_order")
public class SysOrder implements Serializable {

    @TableId(value = "id", type = IdType.AUTO)
    @ApiModelProperty(value = "主键，自增ID")
    private Long id;

    @NotNull
    @ApiModelProperty(value = "用户ID，关联到sys_user表")
    private Long userId;

    @NotNull
    @ApiModelProperty(value = "预约ID，关联到预约表")
    private Long appointmentId;

    @NotBlank
    @ApiModelProperty(value = "订单号，唯一标识每个订单")
    private String orderNumber;

    @NotNull
    @ApiModelProperty(value = "订单总金额，精确到小数点后两位")
    private BigDecimal totalAmount;

    @NotBlank
    @ApiModelProperty(value = "支付方式，如支付宝、微信支付、银行卡等")
    private String paymentMethod;

    @NotNull
    @ApiModelProperty(value = "支付状态：0 - 未支付；1 - 已支付；2 - 支付失败")
    private Integer paymentStatus;

    @ApiModelProperty(value = "支付时间，记录实际支付完成的时间")
    private Timestamp paymentTime;

    @ApiModelProperty(value = "第三方交易号，例如支付宝交易号")
    private String thirdPartyTransactionId;

    @NotNull
    @ApiModelProperty(value = "退款状态：0 - 未退款；1 - 申请中；2 - 已退款；3 - 退款失败")
    private Integer refundStatus;

    @ApiModelProperty(value = "退款金额，如果发生部分退款，这里记录实际退款的金额")
    private BigDecimal refundAmount;

    @ApiModelProperty(value = "退款原因，简要描述退款的原因，如“重复支付”、“医生取消预约”等")
    private String refundReason;

    @ApiModelProperty(value = "退款时间，记录实际退款完成的时间")
    private Timestamp refundTime;

    @ApiModelProperty(value = "创建时间，订单创建的时间")
    private Timestamp createTime;

    @ApiModelProperty(value = "更新时间，每次修改订单时自动更新此字段")
    private Timestamp updateTime;

    public void copy(SysOrder source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
